<?php
class Model_Message extends Model
{
	
	//get message by id
	public function getMessage($id)	{
		$query = DB::select()->from('message')->where('id', '=', $id);
		return $query->execute()->as_array();
	}
	
	/**
	 * Returns all the twitter messages of the last minute
	 */
	public function getTwitterStream($parameters) {
		$array = array(array("getTwitterStream" => $parameters));
		$json = new Helper_Json;
		return $json->send_request($array);
	}
	
	public function getNewMessages($parameters)	{
		$array =  array(array("getNewMessages" => $parameters));
		$json = new Helper_Json;
		return $json->send_request($array);	
	}
	
	/**
	 * Lets the user send a query to the twitter database
	 * 
	 * @param array $parameters
	 */
	public function getTwitterQuery($parameters, $num_tweets){
		$array = array(array("getTwitterQuery" => $parameters, "maxTweets" => $num_tweets));
		$json = new Helper_Json;
		return $json->send_request($array);
	}
}